﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace YiNing.UI.Controls
{
    public partial class WaferMapping : UserControl
    {
        [DllImport("user32")]
        private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, IntPtr lParam);
        private const int WM_SETREDRAW = 0xB;
        public WaferMapping()
        {
            InitializeComponent();
            hScrollBar1.LargeChange = 1;
            hScrollBar1.Maximum = Convert.ToInt32(wafermap1.Height * 0.6);
            vScrollBar1.LargeChange = 1;
            vScrollBar1.Maximum = Convert.ToInt32(wafermap1.Height * 0.6);
        }

        public void Showddddd()
        {
            wafermap1.Colors = new Color[] { Color.DimGray, Color.Blue };
            Die[,] data = new Die[390, 400];
            Random binGenerator = new Random(1);
            for (int x = 0; x < 390; x++)
            {
                for (int y = 0; y < 400; y++)
                {
                    data[x, y] = new Die() { ColorIndex = 1, XIndex = x, YIndex = y, XPluse = 0, YPluse = 0 };// 
                }
            }
            wafermap1.Dataset = data;
            wafermap1.Notchlocation = 0;
            //wmap.MinimumSize = new Size(500, 500);
            wafermap1.Interactive = false;
        }



        private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {
            wafermap1.Location = new Point(wafermap1.Location.X, wafermap1.Location.Y + (e.OldValue - e.NewValue));
            Console.WriteLine(e.NewValue);
        }

        private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {
            wafermap1.Location = new Point(wafermap1.Location.X + e.OldValue - e.NewValue, wafermap1.Location.Y);
        }
    }
}
